package 力扣日常刷题.木23一月.第09天309;

import 力扣日常刷题.ListNode;

/**
 * @author 帅小伙
 * @date 2022/3/9
 * @description
 */
public class Demo36两个链表的第一个交点 {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode curA = headA;
        ListNode curB = headB;

        while(curA != curB) {
            curA = curA != null ? curA.next : headB;
            curB = curB != null ? curB.next : headA;
        }
        return curA;
    }

}
